package com.example.acitividemo2.config;

import cn.hutool.core.util.ArrayUtil;
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.stereotype.Component;

//@Component
public class ConfigurationApplicationContextInitializer implements
        ApplicationContextInitializer<ConfigurableApplicationContext>,
        ApplicationListener<ApplicationStartedEvent>{
    @Override
    public void initialize(ConfigurableApplicationContext applicationContext) {

        System.out.println("----------------------------------applicationContext");
        System.out.println("----------------------------------applicationContext");
        System.out.println("----------------------------------applicationContext");
        System.out.println("----------------------------------applicationContext");
        System.out.println("----------------------------------applicationContext");
        System.out.println(applicationContext);


        String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();

        System.out.println(ArrayUtil.join(beanDefinitionNames, ","));

    }

    @Override
    public void onApplicationEvent(ApplicationStartedEvent event) {
        System.out.println("event");
        System.out.println(event);
    }
}
